/*
 *      codecs.hpp
 *
 *      Copyright 2007 Marcelo Araujo <<araujo@FreeBSD.org>>
 *
 *      Copyright (c) 2007 Marcelo S. Araujo
 *      All rights reserved.
 *
 *      Redistribution and use in source and binary forms, with or without
 *      modification, are permitted provided that the following conditions are
 *      met:
 *
 *      * Redistributions of source code must retain the above copyright
 *        notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following disclaimer
 *        in the documentation and/or other materials provided with the
 *        distribution.
 *      * Neither the name of the Intelbras nor the names of its
 *        contributors may be used to endorse or promote products derived from
 *        this software without specific prior written permission.
 *
 *      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *      "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *      LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *      A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *      OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *      LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *      THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *      OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 */

//
// Code Style by: K&R
//


struct Type_Codecs {
		float Codec_Bandwith;
} TC, *TCodecs;

class Codecs {

	public: // Seto o valor de cada codec ja com o header e frames ethernet(By cisco).
		float type;
		float Bandwith_Codecs(int offtype);
		float Bandwith_Calc(float B_Codec, int users);
};

float Codecs::Bandwith_Codecs(int offtype) {
	TCodecs = &TC;
	switch(offtype) {
		case 1:
			TCodecs->Codec_Bandwith = 87.2;
			type = TCodecs->Codec_Bandwith;
			break;
		case 2:
			TCodecs->Codec_Bandwith = 31.2;
			type = TCodecs->Codec_Bandwith;
			break;
		case 3:
			TCodecs->Codec_Bandwith = 21.65;
			type = TCodecs->Codec_Bandwith;
			break;
		case 4:
			TCodecs->Codec_Bandwith = 55.2;
			type = TCodecs->Codec_Bandwith;
			break;
		case 5:
			TCodecs->Codec_Bandwith = 36.4;
			type = TCodecs->Codec_Bandwith;
			break;
		case 6:
			TCodecs->Codec_Bandwith = 38.4;
			type = TCodecs->Codec_Bandwith;
			break;
		case 7:
			TCodecs->Codec_Bandwith = 31.2;
			type = TCodecs->Codec_Bandwith;
			break;
	}
	return type;
}

float Codecs::Bandwith_Calc(float B_Codec, int users) {
	float result;
	float t_users;
	float t_signal;
	t_users = B_Codec * users;
	t_signal = t_users / 100 * 5; // 5% da sinalizacao.
	result = t_users + t_signal;
	return result;
}

class Users {
	public:
		int Users_Calc(float Link_Bandwith, float Codec_Bandwith);
};

int Users::Users_Calc(float Link_Bandwith, float Codec_Bandwith) {
	float result;
	float t_signal;
	result = Link_Bandwith / Codec_Bandwith;
	t_signal = result / 100 * 5;
	result = result - t_signal; // Removo o 5% de sinalizacao.
	return result;
}
